package com.xuan.wcdialog;

import com.xuan.wcdialog.WCPromptDialog.PromptDialogListener;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;

public class Main extends Activity {

    private LinearLayout content;
    
    private WCPromptDialog p;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        content = (LinearLayout) findViewById(R.id.content);

        addButton("WCAlertDialog", new Button.OnClickListener() {
            @Override
            public void onClick(View view) {
                WCAlertDialog d = new WCAlertDialog.Builder(Main.this).setTitle("温馨提示").setMessage("徐安是个好人").create();
                d.show();
            }
        });
        
        addButton("WCConfirmDialog", new Button.OnClickListener() {
            @Override
            public void onClick(View view) {
            	WCConfirmDialog d = new WCConfirmDialog.Builder(Main.this).setTitle("温馨提示").setMessage("徐安是个好人").setLeftBtnText("OK").setRightBtnText("Cancel").create();
                d.show();
            }
        });
        
        addButton("WCPromptDialog", new Button.OnClickListener() {
            @Override
            public void onClick(View view) {
            	p = new WCPromptDialog.Builder(Main.this).setTitle("WCPromptDialog").setMessage("WCPromptDialog Message").setOnLeftBtnListener(new PromptDialogListener() {
					@Override
					public void onClick(View view, String inputText) {
						Toast.makeText(Main.this,inputText,Toast.LENGTH_SHORT).show();
						p.dismiss();
					}
				}).create();
                p.show();
            }
        });
    }

    private void addButton(String text, final Button.OnClickListener onClickListener) {
        Button button = new Button(Main.this);
        button.setText(text);
        button.setOnClickListener(onClickListener);
        content.addView(button);
    }
}
